Append text to a file and display the textΒΆ

Append text to a file and display the text.
def file_write(fname):

    with open(fname, "w") as myfile:
        myfile.write("Python Exercises\n")
        myfile.write("Java Exercises")

    # check
    txt = open(fname)
    print(txt.read())

file_write('abc.txt')

Output:

Python Exercises
Java Exercises